home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / BIT.ASM < prev    next >
Assembly Source File  |  1993-05-04  |  971b  |  44 lines

  1. ;***************************************
  2. ; This OBJ module defines a routine to
  3. ; return the value of a particular bit,
  4. ; in other words, a power of 2:
  5. ;
  6. ;   n = BIT(x)
  7. ;
  8. ;     where
  9. ;
  10. ;   n = 2^(x-1)
  11. ;
  12. ; Defines:
  13. ;
  14. ;   BIT  return bit value
  15. ;
  16. ; Assemble as:
  17. ;
  18. ;   WASM bit bit.obj
  19.  
  20.         INCLUDE 'object.inc'
  21.  
  22.         INIT    'BIT.ASM', '_TEXT', 'CODE', ALIGN_BYTE + COMBINE_PUBLIC
  23.  
  24.         PUBLIC  BIT, 'BIT'
  25.  
  26.         BEGIN
  27.  
  28. BIT     PROC    FAR
  29.         push    bp
  30.         mov     bp, sp
  31.         mov     cx, [bp+6]      ;load bit number
  32.         mov     ax, 1           ;bit zero
  33.         sub     dx, dx          ;zero high word
  34.         sub     cx, 1           ;decrement
  35.         jbe     bit2            ;exit if done
  36. bit1    shl     ax              ;shift low word
  37.         rcl     dx              ;shift high word
  38.         loop    bit1            ;loop for count
  39. bit2    pop     bp
  40.         ret     2
  41.         ENDP
  42.  
  43.         END
  44.